﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SistemaPetShop.Negocio;

namespace SistemaPetShop.Forms
{
    public partial class conHistoricoBanhoTosa : Form
    {
        Animal animal = new Animal();
        Cliente cliente = new Cliente();
        Agenda agenda = new Agenda();

        public conHistoricoBanhoTosa()
        {
            InitializeComponent();
            _CarregaComboCliente();
        }

        private void _CarregaComboCliente()
        {
            cboCliente.DataSource = cliente._ListaNomeCliente();
            cboCliente.DisplayMember = "nome";
            cboCliente.ValueMember = "idCliente";
            _CarregaComboAnimal();
        }

        private void _CarregaGridHistorico()
        {
            GridViewHistoricoBanho.DataSource = agenda._ListaHistoricoCliente(Convert.ToInt32(cboCliente.SelectedValue.ToString()), Convert.ToInt32(cboApelido.SelectedValue.ToString()));
        }

        private void _CarregaComboAnimal()
        {

            if (cboCliente.SelectedValue.ToString() != "System.Data.DataRowView")
            {
                cboApelido.DataSource = animal._ListaNomeAnimal(Convert.ToInt32(cboCliente.SelectedValue.ToString()));
                cboApelido.DisplayMember = "apelido";
                cboApelido.ValueMember = "idAnimal";
            }


        }

        private void btnPesquisar_Click(object sender, EventArgs e)
        {
            _CarregaGridHistorico();
        }
    }
}
